package com.int_tech.car.dao;

import com.int_tech.car.entity.Car;
import com.int_tech.car.entity.CarOpenInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by liubch on 2017/11/20.
 */
public interface CarOpenInfoDao extends JpaRepository<CarOpenInfo,Integer> {
    
//    @Query("select c from CarOpenInfo c where c.stationId=?1 order by c.messionNumber desc ,c.createTime desc")
//    List<CarOpenInfo> findByStationId(int stationId);

    List<CarOpenInfo> findByAddress(String address);

    CarOpenInfo findByCarNumberAndOpenStatus(String carNumber, int s);

    CarOpenInfo findFirstByCarNumberAndOpenStatusOrderByCreateTimeDesc(String carNumber, int s);

    List<CarOpenInfo> findByStationIdOrderByCreateTimeDesc(int stationId);

    @Query("select c from CarOpenInfo c where c.stationId=?1 order by c.messionNumber desc ,c.createTime desc")
    List<CarOpenInfo> findCTimeAndMNumber(int stationId);

    List<CarOpenInfo> findByStationIdOrderByCreateTimeDescMessionNumberDesc(int stationId);

    List<CarOpenInfo> findByStationIdOrderByCreateTimeDescMessionNumberAsc(int stationId);

    List<CarOpenInfo> findByStationIdOrderByCreateTimeAscMessionNumberAsc(int stationId);

    List<CarOpenInfo> findByStationIdOrderByMessionNumberAscCreateTimeAsc(int stationId);

    /*@Query("select s from CarOpenInfo c where c.stationId=?1 order by c.messionNumber desc ,c.createTime desc")
    List<CarOpenInfo> findByStationIdOrderByCreateTimeAndMessionNumberDesc(int stationId);*/
    /*@Query("select s from CarOpenInfo c where c.stationId=?1 order by c.messionNumber desc ,c.createTime desc")
    List<CarOpenInfo> findByStationIdCTimeAndMNumber(int stationId);*/
}
